package cn.legend.travel.destination.keyword.controller;

import cn.legend.travel.common.web.JsonResult;
import cn.legend.travel.destination.keyword.pojo.po.HotMonthDestinationPO;
import cn.legend.travel.destination.keyword.service.IKeywordService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/keyword/")
@Validated
@Api(tags = "自动补全")
public class KeywordController {
    @Autowired
    private IKeywordService keywordService;
    public KeywordController() {
        log.debug("创建控制器类对象：KeywordController");
    }
    @GetMapping("/getKeyword")
    @ApiOperation("根据父级查询子级地区列表")
    @ApiOperationSupport(order = 420)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "search", value = "搜索词", required = true, dataType = "String", example = "")
    })
    public JsonResult MonthDestinationList(@RequestParam String search) {
        List<String> suggestion = keywordService.getSuggestion(search);
        return JsonResult.ok(suggestion);
    }


}
